<!DOCTYPE html>
<html>
<head>
    <title>首页</title>
    <#include "head.ftl"/>
</head>
<body>

<form class="layui-form" action="">
    <div class="edit-bar">
        <button type="submit" class="layui-btn layui-btn-sm" lay-submit="" lay-filter="save">保&nbsp;&nbsp;存</button>
    </div>
    <div class="layui-row edit-form">
        <div class="layui-col-md12">
            <label class="layui-form-label">原密码</label>
            <div class="layui-input-inline">
                <input type="password" maxlength="64" lay-verify="required" value="" name="oldpwd" autocomplete="off" placeholder="请输入内容" class="layui-input"/>
            </div>
        </div>
        <div class="layui-col-md12">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-inline">
                <input type="password" maxlength="64" lay-verify="required" value="" name="newpwd" autocomplete="off" placeholder="请输入内容" class="layui-input"/>
            </div>
        </div>
        <div class="layui-col-md12">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-inline">
                <input type="password" maxlength="64" lay-verify="required" value="" name="confirmpwd" autocomplete="off" placeholder="请输入内容" class="layui-input"/>
            </div>
        </div>
    </div>
</form>
<script type="application/javascript">
    //UI初始化
    layui.use(['element','layer', 'form','table'], function () {
        var form = layui.form;
        var layer = layui.layer;
        //自定义验证规则
        form.verify(verify_rule);
        //监听提交
        form.on('submit(save)', function(data){
            if(data.field.newpwd!=data.field.confirmpwd){
                layer.msg("新密码和确认密码不一致", {icon: 5, shift: 6});
                return false;
            }
            $.ajax({
                url: "/data/changepwd",
                dataType: "json",
                method: "POST",
                data: data.field,
                success: function (result) {
                    if(result.code>0){
                        layer.msg(result.msg,{
                            time: 1000
                        });
                    }else{
                        layer.msg(result.msg, {icon: 5, shift: 6});
                    }

                }
            });
            return false;
        });
    });
</script>
</body>
</html>